/**
 * 任务相关接口类型定义
 */

import { BaseApiResponse } from "./interface";


// 任务基本信息
export interface TaskInfo {
  id: string;
  title: string;
  description?: string;
  taskType: number; // 任务类型：1-每日任务，2-周任务，3-月任务，4-一次性任务
  category?: string;
  targetValue: number; // 目标值
  currentValue?: number; // 当前进度值
  status: number; // 状态：0-未开始，1-进行中，2-已完成，3-已领奖
  priority?: number;
  startTime?: Date;
  endTime?: Date;
  createTime?: Date;
  icon?: string;
  tags?: string[];
}

// 任务奖励信息
export interface TaskReward {
  experienceReward: number;
  pointsReward: number;
  itemRewards?: {
    itemId: string;
    itemName: string;
    quantity: number;
    itemType?: string;
  }[];
  specialRewards?: any[];
}

// 用户任务进度
export interface UserTaskProgress extends TaskInfo {
  userTaskId: string;
  progress: number; // 进度百分比 0-100
  isCompleted: boolean;
  isRewardClaimed: boolean;
  completedTime?: Date;
  rewardClaimedTime?: Date;
  reward: TaskReward;
}

// 用户可用任务列表响应
export interface UserAvailableTasksResponse {
  tasks: UserTaskProgress[];
  summary: {
    totalTasks: number;
    completedTasks: number;
    pendingTasks: number;
    availableRewards: number;
  };
}

export interface UserAvailableTasksApiResponse extends BaseApiResponse<UserAvailableTasksResponse> {}

// 完成任务响应
export interface CompleteTaskResponse {
  success: boolean;
  taskId: string;
  previousProgress: number;
  newProgress: number;
  isCompleted: boolean;
  autoCompleted?: boolean;
  message?: string;
}

export interface CompleteTaskApiResponse extends BaseApiResponse<CompleteTaskResponse> {}

// 领取任务奖励响应
export interface ClaimTaskRewardResponse {
  success: boolean;
  taskId: string;
  reward: TaskReward;
  newUserStats: {
    experience: number;
    points: number;
    level?: number;
  };
  message?: string;
}

export interface ClaimTaskRewardApiResponse extends BaseApiResponse<ClaimTaskRewardResponse> {}

// 自动检查任务完成状态响应
export interface AutoCheckTaskResponse {
  success: boolean;
  checkedTasks: number;
  completedTasks: string[];
  message: string;
}

export interface AutoCheckTaskApiResponse extends BaseApiResponse<AutoCheckTaskResponse> {}
